package com.hzya.frame.utils.help;

import freemarker.cache.URLTemplateLoader;

import java.net.URL;

/**
 * @description:
 * @author: gjh
 * @Date Created in ${Data} 14:25
 */
public   class SevenStarClassTemplateLoader extends URLTemplateLoader {
    public SevenStarClassTemplateLoader() {
    }

    protected URL getURL(String name) {
        return getResource(name, this.getClass());
    }

    public static URL getResource(String resourceName, Class callingClass) {
        URL url = null;
        url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
        if (url == null) {
            url = SevenStarClassTemplateLoader.class.getClassLoader().getResource(resourceName);
        }

        if (url == null) {
            url = callingClass.getClassLoader().getResource(resourceName);
        }

        return url;
    }
}
